package nix.servlet;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * 实现Servlet接口
 * 
 * @author berry
 * 
 */
public class AServlet implements Servlet {

	@Override
	public void destroy() {
		System.out.println("destroy()...");
	}

	@Override
	public ServletConfig getServletConfig() {
		System.out.println("getServletConfig()...");
		return null;
	}

	@Override
	public String getServletInfo() {
		System.out.println("getServletInfo()...");
		return null;
	}

	@Override
	public void init(ServletConfig servletConfig) throws ServletException {
		System.out.println("init()...");

		Enumeration e = servletConfig.getInitParameterNames();
		while (e.hasMoreElements()) {
			System.out.println(e.nextElement());
		}

		System.out.println(servletConfig.getInitParameter("p1"));
		System.out.println(servletConfig.getInitParameter("p2"));
	}

	@Override
	public void service(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		System.out.println("service()...");
	}

}
